package com.qqt.csr.archive.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qqt.csr.archive.entity.reader.CsrRoomMember;
import com.qqt.csr.archive.mapper.CsrRoomMemberMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @Author: yang hao
 * @Date: 2024/11/19 19:49
 * @Description: 房间成员 服务
 **/
@Slf4j
@Service
public class CsrRoomMemberService extends ServiceImpl<CsrRoomMemberMapper, CsrRoomMember> {

    /**
     * 根据房间id获取房间成员列表
     * @param roomId {@link String} 房间id
     * @return {@link List<CsrRoomMember>} 房间成员列表
     */
    public List<CsrRoomMember> getRoomMembers(String roomId) {
        LambdaQueryWrapper<CsrRoomMember> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(CsrRoomMember::getRoomId, roomId);
        List<CsrRoomMember> members = this.baseMapper.selectList(wrapper);
        if (members == null || members.isEmpty()) {
            return Collections.emptyList();
        }
        return members;
    }

}
